﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using MvcContrib.FluentHtml;

using Revis.VClinicNet.App.Internal.Dto;
using Revis.VClinicNet.Core.Domain.Credentials;
using Revis.VClinicNet.Util.Translation;

namespace Revis.VClinicNet.UI.Internal.Mvc.Models
{
    public class WorkerUserCreateFormModel : WorkerUserCreateDto
    {
        public WorkerUserCreateFormModel()
            : this(new WorkerUserCreateDto())
        {
        }

        public WorkerUserCreateFormModel(WorkerUserCreateDto worker)
        {
            FirstName = worker.FirstName;
            Surname = worker.Surname;
            Login = worker.Login;
            Password = worker.Password;
            RepeatedPassword = worker.RepeatedPassword;
            IsActive = worker.IsActive;
            Role = worker.Role;
        }

        public IEnumerable<SelectListItem> Roles
        {
            get
            {
                List<SelectListItem> items = new List<SelectListItem>();
                foreach (WorkerUserRole role in Enum.GetValues(typeof(WorkerUserRole))) {
                    items.Add(new SelectListItem() {
                        Text = role.ToPLString(),
                        Value = ((int)role).ToString(),
                        Selected = Role == role
                    });
                }
                return items;
            }
        }
    }
}